package org.wu.spring.db.integration.compare.infrastructure.persistence;

import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.stereotype.Repository;
import org.wu.spring.db.integration.compare.domain.model.sys.user.SysUser;
import org.wu.spring.db.integration.compare.domain.model.sys.user.DbComparisonRepository;
import org.wu.spring.db.integration.compare.domain.model.sys.user.SysUserRepository;

import java.util.List;
/**
 * describe sys_user 
 *
 * @author Jia wei Wu
 * @date 2024/02/28 11:27 上午
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class SysUserRepositoryImpl implements  SysUserRepository {

    private final List<DbComparisonRepository> ormTypeRepositoryList;

    public SysUserRepositoryImpl(List<DbComparisonRepository> ormTypeRepositoryList) {
        this.ormTypeRepositoryList = ormTypeRepositoryList;
    }

    /**
     * describe 批量新增
     *
     * @param rowSize    @return {@link Result<List<SysUser>>} 新增后领域对象集合
     * @param columnSize
     * @author Jia wei Wu
     * @date 2024/02/28 11:27 上午
     **/
    @Override
    public Result<List<SysUser>> batchStory(int rowSize, int columnSize) throws Exception {
        for (DbComparisonRepository dbComparisonRepository : ormTypeRepositoryList) {
         try {
             dbComparisonRepository.batchStory(rowSize,columnSize);
         }catch (Exception e){
             e.printStackTrace();
         }
        }
        return ResultFactory.successOf();
    }


    /**
     * describe 分页查询多个
     *
     * @param rowSize    当前页数
     * @param columnSize
     * @return {@link Result<LazyPage<SysUser>>} 分页领域对象
     * @author Jia wei Wu
     * @date 2024/02/28 11:27 上午
     **/
    @Override
    public Result<LazyPage<SysUser>> findPage(int rowSize, int columnSize) throws Exception {
        for (DbComparisonRepository DbComparisonRepository : ormTypeRepositoryList) {
            DbComparisonRepository.findPage(rowSize, columnSize);
        }
        return ResultFactory.successOf();
    }

}